﻿@using Classified.Domain.Entities
@using MvcPaging
@model IPagedList<Country>
<div id="dvCountrylist">
    <h1>
        List of <small>Country</small></h1>
    <p align="right" style="float: left" class="noprint">
        <a href="javascript:void(0);" class="btn newDetailLocation btn-info"><i class="icon-plus icon-white">
        </i>[+] Create new</a>
    </p>
    <table class="table table-bordered table-striped">
        <thead>
            <th>
                Country Name
            </th>
            <th>
                Iso Code(Two)
            </th>
            <th>
                Currency
            </th>
            <th>
                Curreny ISO Code
            </th>
            <th>
                Currency Sign
            </th>
            <th>
            </th>
        </thead>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.Name)
                </td>
                <td>
                    @item.TwoLetterIsoCode
                </td>
                <td>
                    @if (item.Currencies.Count() > 0 && item.Currencies != null)
                    {
                        @item.Currencies.FirstOrDefault().Currency_Name
                    }
                </td>
                <td>
                    @if (item.Currencies.Count() > 0 && item.Currencies != null)
                    {
                        @item.Currencies.FirstOrDefault().ISO_Code
                    }
                </td>
                <td>
                    @if (item.Currencies.Count() > 0 && item.Currencies != null)
                    {
                        @item.Currencies.FirstOrDefault().Currency_Sign
                    }
                </td>
                <td>
                    <a class="btn" href="@Url.Action("Locations", "Admin", new { countryId = item.Id })">
                        <i class="icon-list"></i>Add Area</a> <a href="@Url.Action("EditCountry", "Admin", new { id = item.Id })" class="btn editLocationDetails" idLocationDetails="@item.Id">
                            <i class="icon-edit"></i>Edit</a> <a href="@Url.Action("DeleteCountry", "Admin", new { id = item.Id })" class="btn btn-danger" onclick="return confirm('Are you sure you wish to delete this Country and all its State?');">
                                <i class="icon-trash icon-white"></i>Delete</a>
                </td>
            </tr>
        }
    </table>
    @if (Model.TotalItemCount > 0)
    {
        <div class="pagingContainer noprint">
            @Ajax.Pager(Model.PageSize, Model.PageNumber, Model.TotalItemCount, new AjaxOptions { UpdateTargetId = "locationDetailsList" })
        </div>
    }
</div>
